/**
 * @author sigit <br>
 * @version 1.0 <br>
 * Application : timesheet <br>
 * Copyright (c) fastwire-group 2012 <br>
 * <br>
 */
package com.fw.timesheet.dao;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.fw.timesheet.model.Assignee;


/**
 * @author Lenovo
 *
 */
public class AssigneeDAO extends BaseDAO {

private static final Log log = LogFactory.getLog(AssigneeDAO.class);
	
	public void save(Assignee transientInstance) {
		log.debug("saving Assignee instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public void saveOrUpdate(Object transientInstance) {
		log.debug("saving Assignee instance");
	    try {
	    	Assignee assignee = (Assignee) getHibernateTemplate().merge(transientInstance);
	        getHibernateTemplate().saveOrUpdate(assignee);
	        log.debug("save successful");
	    } catch (RuntimeException re) {
	    	log.error("save failed", re);
	    	throw re;
	    }
	}

	public void delete(Assignee persistentInstance) {
		log.debug("deleting Assignee instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public Assignee findById(java.lang.Long id) {
		log.debug("getting Client instance with id: " + id);
		try {
			Assignee instance = (Assignee) getHibernateTemplate()
					.get("com.fw.timesheet.model.Assignee", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(Assignee instance) {
		log.debug("finding Assignee instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding Assignee instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from Assignee as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}
}
